package com.skyline.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.skyline.base.dao.SiteDao;
import com.skyline.base.model.Site;
import com.skyline.base.service.SiteService;

/**
 * 行政地点模块的Service实现
 * 
 * @author Jairus Chan
 * @version 0.1
 * */
@Service("siteService")
public class SiteServiceImpl implements SiteService {
	@Autowired
	private SiteDao siteDao;
	
	@Override
	public String getCountryID(String siteID) {
		return siteID.substring(0, 3) + "000000";
	}

	@Override
	public String getProvinceID(String siteID) {
		return siteID.substring(0, 5) + "0000";
	}

	@Override
	public String getCityID(String siteID) {
		return siteID.substring(0, 7) + "00";
	}

	@Override
	public List<Site> getAllCountries() {
		return siteDao.queryAllNations();
	}

	@Override
	public List<Site> getSubSites(String siteID) {
		return siteDao.querySubSites(siteID);
	}

	@Override
	public boolean isSameSity(String siteID1, String siteID2) {
		if(siteID1==null || siteID2==null) {
			return true;
		} else {
			return siteID1.equals(siteID2);
		}
	}

}
